/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SnpDbHandling;

import SnpDbEntities.User;
import java.io.Serializable;

/**
 *
 * @author Łukasz 'byku' Guzik
 */
public abstract class UserPermissionsPolicy implements Serializable
{
    protected final User askingUser;

    protected UserPermissionsPolicy(User askingUser)
    {
	this.askingUser = askingUser;
    }

    static public UserPermissionsPolicy getInstance(User forUser)
    {
	switch(forUser.getPermissions())
	{
	    case SUPER_ADMIN:
		return new SuperAdminPermissionsPolicy(forUser);

	    case ADMIN:
		return new AdminPermissionsPolicy(forUser);

	    case MODERATOR:
		return new ModeratorPermissionsPolicy(forUser);

	    default:
		return new NormalUserPermissionsPolicy(forUser);
	}
    }

    public abstract boolean canAddUser(User userToAdd);

    public abstract boolean canDeleteUser(User userToDelete);

    public abstract boolean canDisEnableUser(User userToDisEnable);

    public abstract boolean canUpdateUser(User userToUpdate, User newUserData);

    public abstract boolean canChangePublicCategories();

    public abstract boolean canUpdatePublicSnippet();
}
